package com.kuzan.autocloud.client.sys.config;

import com.google.common.io.CharStreams;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * <p>Description: </p>
 *
 * @author kuzank
 */
public interface Initialize {

    void initializedb() throws Exception;

    default String getResourcesFileContent(String filepath) throws IOException {

        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        Resource[] resources = resolver.getResources(String.format("classpath:%s", filepath));
        InputStream in = resources[0].getInputStream();

        return CharStreams.toString(new InputStreamReader(in, "UTF-8"));
    }
}
